<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>iparmq.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      INTEGER FUNCTION <a name="IPARMQ.1"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a>( ISPEC, NAME, OPTS, N, ILO, IHI, LWORK )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK auxiliary routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">     
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      INTEGER            IHI, ILO, ISPEC, LWORK, N
      CHARACTER          NAME*( * ), OPTS*( * )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       This program sets problem and machine dependent parameters
</span><span class="comment">*</span><span class="comment">       useful for xHSEQR and its subroutines. It is called whenever 
</span><span class="comment">*</span><span class="comment">       <a name="ILAENV.16"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a> is called with 12 &lt;= ISPEC &lt;= 16
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       ISPEC  (input) integer scalar
</span><span class="comment">*</span><span class="comment">              ISPEC specifies which tunable parameter <a name="IPARMQ.22"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a> should
</span><span class="comment">*</span><span class="comment">              return.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              ISPEC=12: (INMIN)  Matrices of order nmin or less
</span><span class="comment">*</span><span class="comment">                        are sent directly to xLAHQR, the implicit
</span><span class="comment">*</span><span class="comment">                        double shift QR algorithm.  NMIN must be
</span><span class="comment">*</span><span class="comment">                        at least 11.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              ISPEC=13: (INWIN)  Size of the deflation window.
</span><span class="comment">*</span><span class="comment">                        This is best set greater than or equal to
</span><span class="comment">*</span><span class="comment">                        the number of simultaneous shifts NS.
</span><span class="comment">*</span><span class="comment">                        Larger matrices benefit from larger deflation
</span><span class="comment">*</span><span class="comment">                        windows.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              ISPEC=14: (INIBL) Determines when to stop nibbling and
</span><span class="comment">*</span><span class="comment">                        invest in an (expensive) multi-shift QR sweep.
</span><span class="comment">*</span><span class="comment">                        If the aggressive early deflation subroutine
</span><span class="comment">*</span><span class="comment">                        finds LD converged eigenvalues from an order
</span><span class="comment">*</span><span class="comment">                        NW deflation window and LD.GT.(NW*NIBBLE)/100,
</span><span class="comment">*</span><span class="comment">                        then the next QR sweep is skipped and early
</span><span class="comment">*</span><span class="comment">                        deflation is applied immediately to the
</span><span class="comment">*</span><span class="comment">                        remaining active diagonal block.  Setting
</span><span class="comment">*</span><span class="comment">                        <a name="IPARMQ.44"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a>(ISPEC=14) = 0 causes TTQRE to skip a
</span><span class="comment">*</span><span class="comment">                        multi-shift QR sweep whenever early deflation
</span><span class="comment">*</span><span class="comment">                        finds a converged eigenvalue.  Setting
</span><span class="comment">*</span><span class="comment">                        <a name="IPARMQ.47"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a>(ISPEC=14) greater than or equal to 100
</span><span class="comment">*</span><span class="comment">                        prevents TTQRE from skipping a multi-shift
</span><span class="comment">*</span><span class="comment">                        QR sweep.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              ISPEC=15: (NSHFTS) The number of simultaneous shifts in
</span><span class="comment">*</span><span class="comment">                        a multi-shift QR iteration.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              ISPEC=16: (IACC22) <a name="IPARMQ.54"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a> is set to 0, 1 or 2 with the
</span><span class="comment">*</span><span class="comment">                        following meanings.
</span><span class="comment">*</span><span class="comment">                        0:  During the multi-shift QR sweep,
</span><span class="comment">*</span><span class="comment">                            xLAQR5 does not accumulate reflections and
</span><span class="comment">*</span><span class="comment">                            does not use matrix-matrix multiply to
</span><span class="comment">*</span><span class="comment">                            update the far-from-diagonal matrix
</span><span class="comment">*</span><span class="comment">                            entries.
</span><span class="comment">*</span><span class="comment">                        1:  During the multi-shift QR sweep,
</span><span class="comment">*</span><span class="comment">                            xLAQR5 and/or xLAQRaccumulates reflections and uses
</span><span class="comment">*</span><span class="comment">                            matrix-matrix multiply to update the
</span><span class="comment">*</span><span class="comment">                            far-from-diagonal matrix entries.
</span><span class="comment">*</span><span class="comment">                        2:  During the multi-shift QR sweep.
</span><span class="comment">*</span><span class="comment">                            xLAQR5 accumulates reflections and takes
</span><span class="comment">*</span><span class="comment">                            advantage of 2-by-2 block structure during
</span><span class="comment">*</span><span class="comment">                            matrix-matrix multiplies.
</span><span class="comment">*</span><span class="comment">                        (If xTRMM is slower than xGEMM, then
</span><span class="comment">*</span><span class="comment">                        <a name="IPARMQ.70"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a>(ISPEC=16)=1 may be more efficient than
</span><span class="comment">*</span><span class="comment">                        <a name="IPARMQ.71"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a>(ISPEC=16)=2 despite the greater level of
</span><span class="comment">*</span><span class="comment">                        arithmetic work implied by the latter choice.)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       NAME    (input) character string
</span><span class="comment">*</span><span class="comment">               Name of the calling subroutine
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       OPTS    (input) character string
</span><span class="comment">*</span><span class="comment">               This is a concatenation of the string arguments to
</span><span class="comment">*</span><span class="comment">               TTQRE.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       N       (input) integer scalar
</span><span class="comment">*</span><span class="comment">               N is the order of the Hessenberg matrix H.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       ILO     (input) INTEGER
</span><span class="comment">*</span><span class="comment">       IHI     (input) INTEGER
</span><span class="comment">*</span><span class="comment">               It is assumed that H is already upper triangular
</span><span class="comment">*</span><span class="comment">               in rows and columns 1:ILO-1 and IHI+1:N.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       LWORK   (input) integer scalar
</span><span class="comment">*</span><span class="comment">               The amount of workspace available.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Further Details
</span><span class="comment">*</span><span class="comment">  ===============
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       Little is known about how best to choose these parameters.
</span><span class="comment">*</span><span class="comment">       It is possible to use different values of the parameters
</span><span class="comment">*</span><span class="comment">       for each of <a name="CHSEQR.97"></a><a href="chseqr.f.html#CHSEQR.1">CHSEQR</a>, <a name="DHSEQR.97"></a><a href="dhseqr.f.html#DHSEQR.1">DHSEQR</a>, <a name="SHSEQR.97"></a><a href="shseqr.f.html#SHSEQR.1">SHSEQR</a> and <a name="ZHSEQR.97"></a><a href="zhseqr.f.html#ZHSEQR.1">ZHSEQR</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       It is probably best to choose different parameters for
</span><span class="comment">*</span><span class="comment">       different matrices and different parameters at different
</span><span class="comment">*</span><span class="comment">       times during the iteration, but this has not been
</span><span class="comment">*</span><span class="comment">       implemented --- yet.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       The best choices of most of the parameters depend
</span><span class="comment">*</span><span class="comment">       in an ill-understood way on the relative execution
</span><span class="comment">*</span><span class="comment">       rate of xLAQR3 and xLAQR5 and on the nature of each
</span><span class="comment">*</span><span class="comment">       particular eigenvalue problem.  Experiment may be the
</span><span class="comment">*</span><span class="comment">       only practical way to determine which choices are most
</span><span class="comment">*</span><span class="comment">       effective.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       Following is a list of default values supplied by <a name="IPARMQ.112"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a>.
</span><span class="comment">*</span><span class="comment">       These defaults may be adjusted in order to attain better
</span><span class="comment">*</span><span class="comment">       performance in any particular computational environment.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       <a name="IPARMQ.116"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a>(ISPEC=12) The xLAHQR vs xLAQR0 crossover point.
</span><span class="comment">*</span><span class="comment">                        Default: 75. (Must be at least 11.)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       <a name="IPARMQ.119"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a>(ISPEC=13) Recommended deflation window size.
</span><span class="comment">*</span><span class="comment">                        This depends on ILO, IHI and NS, the
</span><span class="comment">*</span><span class="comment">                        number of simultaneous shifts returned
</span><span class="comment">*</span><span class="comment">                        by <a name="IPARMQ.122"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a>(ISPEC=15).  The default for
</span><span class="comment">*</span><span class="comment">                        (IHI-ILO+1).LE.500 is NS.  The default
</span><span class="comment">*</span><span class="comment">                        for (IHI-ILO+1).GT.500 is 3*NS/2.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       <a name="IPARMQ.126"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a>(ISPEC=14) Nibble crossover point.  Default: 14.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       <a name="IPARMQ.128"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a>(ISPEC=15) Number of simultaneous shifts, NS.
</span><span class="comment">*</span><span class="comment">                        a multi-shift QR iteration.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                        If IHI-ILO+1 is ...
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                        greater than      ...but less    ... the
</span><span class="comment">*</span><span class="comment">                        or equal to ...      than        default is
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                                0               30       NS =   2+
</span><span class="comment">*</span><span class="comment">                               30               60       NS =   4+
</span><span class="comment">*</span><span class="comment">                               60              150       NS =  10
</span><span class="comment">*</span><span class="comment">                              150              590       NS =  **
</span><span class="comment">*</span><span class="comment">                              590             3000       NS =  64
</span><span class="comment">*</span><span class="comment">                             3000             6000       NS = 128
</span><span class="comment">*</span><span class="comment">                             6000             infinity   NS = 256
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                    (+)  By default matrices of this order are
</span><span class="comment">*</span><span class="comment">                         passed to the implicit double shift routine
</span><span class="comment">*</span><span class="comment">                         xLAHQR.  See <a name="IPARMQ.146"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a>(ISPEC=12) above.   These
</span><span class="comment">*</span><span class="comment">                         values of NS are used only in case of a rare
</span><span class="comment">*</span><span class="comment">                         xLAHQR failure.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                    (**) The asterisks (**) indicate an ad-hoc
</span><span class="comment">*</span><span class="comment">                         function increasing from 10 to 64.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">       <a name="IPARMQ.153"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a>(ISPEC=16) Select structured matrix multiply.
</span><span class="comment">*</span><span class="comment">                        (See ISPEC=16 above for details.)
</span><span class="comment">*</span><span class="comment">                        Default: 3.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     ================================================================
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      INTEGER            INMIN, INWIN, INIBL, ISHFTS, IACC22
      PARAMETER          ( INMIN = 12, INWIN = 13, INIBL = 14,
     $                   ISHFTS = 15, IACC22 = 16 )
      INTEGER            NMIN, K22MIN, KACMIN, NIBBLE, KNWSWP
      PARAMETER          ( NMIN = 75, K22MIN = 14, KACMIN = 14,
     $                   NIBBLE = 14, KNWSWP = 500 )
      REAL               TWO
      PARAMETER          ( TWO = 2.0 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      INTEGER            NH, NS
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          LOG, MAX, MOD, NINT, REAL
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span>      IF( ( ISPEC.EQ.ISHFTS ) .OR. ( ISPEC.EQ.INWIN ) .OR.
     $    ( ISPEC.EQ.IACC22 ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        ==== Set the number simultaneous shifts ====
</span><span class="comment">*</span><span class="comment">
</span>         NH = IHI - ILO + 1
         NS = 2
         IF( NH.GE.30 )
     $      NS = 4
         IF( NH.GE.60 )
     $      NS = 10
         IF( NH.GE.150 )
     $      NS = MAX( 10, NH / NINT( LOG( REAL( NH ) ) / LOG( TWO ) ) )
         IF( NH.GE.590 )
     $      NS = 64
         IF( NH.GE.3000 )
     $      NS = 128
         IF( NH.GE.6000 )
     $      NS = 256
         NS = MAX( 2, NS-MOD( NS, 2 ) )
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( ISPEC.EQ.INMIN ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        ===== Matrices of order smaller than NMIN get sent
</span><span class="comment">*</span><span class="comment">        .     to xLAHQR, the classic double shift algorithm.
</span><span class="comment">*</span><span class="comment">        .     This must be at least 11. ====
</span><span class="comment">*</span><span class="comment">
</span>         <a name="IPARMQ.204"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a> = NMIN
<span class="comment">*</span><span class="comment">
</span>      ELSE IF( ISPEC.EQ.INIBL ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        ==== INIBL: skip a multi-shift qr iteration and
</span><span class="comment">*</span><span class="comment">        .    whenever aggressive early deflation finds
</span><span class="comment">*</span><span class="comment">        .    at least (NIBBLE*(window size)/100) deflations. ====
</span><span class="comment">*</span><span class="comment">
</span>         <a name="IPARMQ.212"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a> = NIBBLE
<span class="comment">*</span><span class="comment">
</span>      ELSE IF( ISPEC.EQ.ISHFTS ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        ==== NSHFTS: The number of simultaneous shifts =====
</span><span class="comment">*</span><span class="comment">
</span>         <a name="IPARMQ.218"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a> = NS
<span class="comment">*</span><span class="comment">
</span>      ELSE IF( ISPEC.EQ.INWIN ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        ==== NW: deflation window size.  ====
</span><span class="comment">*</span><span class="comment">
</span>         IF( NH.LE.KNWSWP ) THEN
            <a name="IPARMQ.225"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a> = NS
         ELSE
            <a name="IPARMQ.227"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a> = 3*NS / 2
         END IF
<span class="comment">*</span><span class="comment">
</span>      ELSE IF( ISPEC.EQ.IACC22 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        ==== IACC22: Whether to accumulate reflections
</span><span class="comment">*</span><span class="comment">        .     before updating the far-from-diagonal elements
</span><span class="comment">*</span><span class="comment">        .     and whether to use 2-by-2 block structure while
</span><span class="comment">*</span><span class="comment">        .     doing it.  A small amount of work could be saved
</span><span class="comment">*</span><span class="comment">        .     by making this choice dependent also upon the
</span><span class="comment">*</span><span class="comment">        .     NH=IHI-ILO+1.
</span><span class="comment">*</span><span class="comment">
</span>         <a name="IPARMQ.239"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a> = 0
         IF( NS.GE.KACMIN )
     $      <a name="IPARMQ.241"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a> = 1
         IF( NS.GE.K22MIN )
     $      <a name="IPARMQ.243"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a> = 2
<span class="comment">*</span><span class="comment">
</span>      ELSE
<span class="comment">*</span><span class="comment">        ===== invalid value of ispec =====
</span>         <a name="IPARMQ.247"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a> = -1
<span class="comment">*</span><span class="comment">
</span>      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     ==== End of <a name="IPARMQ.251"></a><a href="iparmq.f.html#IPARMQ.1">IPARMQ</a> ====
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
